package com.apps.ftapp.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

import androidx.appcompat.app.AppCompatActivity;

import com.apps.ftapp.R;
import com.github.barteksc.pdfviewer.PDFView;

import java.io.File;

public class PdfActivity extends AppCompatActivity {
    private PDFView pdfView;
    private LinearLayout back;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pdf);
        pdfView = findViewById(R.id.pdfView);
        back = findViewById(R.id.back_lin);
        init();
    }

    private void init() {
        Intent intent = getIntent();
        String uri = intent.getStringExtra("uri");
        pdfView.fromFile(new File(uri))
                .defaultPage(0)//默认页面
                .enableDoubletap(true)
                .swipeHorizontal(false)//是不是横向查看
                .enableSwipe(true)
                .load();
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }
}
